package com.example.android.intro;

import java.io.IOException;
import java.io.InputStream;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageView;

public class TutorialThree extends Activity implements OnClickListener{
ImageView display;
int toPhone;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
		setContentView(R.layout.wallpaper);
		
		toPhone=R.drawable.moon1;
		
		display=(ImageView)findViewById(R.id.IVdisplay);
		ImageView image1=(ImageView) findViewById(R.id.IVimage1);
		ImageView image2=(ImageView) findViewById(R.id.IVimage2);
		ImageView image3=(ImageView) findViewById(R.id.IVimage3);
		ImageView image4=(ImageView) findViewById(R.id.IVimage4);
		Button setWall=(Button) findViewById(R.id.BestWallpaper);
		image1.setOnClickListener(this);
		image2.setOnClickListener(this);
		image3.setOnClickListener(this);
		image4.setOnClickListener(this);
		setWall.setOnClickListener(this);
	}
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch(v.getId()){
		case R.id.IVimage1:
			display.setImageResource(R.drawable.moon1);
			toPhone=R.drawable.moon1;
			break;
		case R.id.IVimage2:
			display.setImageResource(R.drawable.moon2);
			toPhone=R.drawable.moon2;
			break;
		case R.id.IVimage3:
			display.setImageResource(R.drawable.moon3);
			toPhone=R.drawable.moon3;
			break;
		case R.id.IVimage4:
			display.setImageResource(R.drawable.moon4);
			toPhone=R.drawable.moon4;
			break;
		case R.id.BestWallpaper:
			InputStream yeaaaa=getResources().openRawResource(toPhone);
			Bitmap whatever =BitmapFactory.decodeStream(yeaaaa);
			try{
				getApplicationContext().setWallpaper(whatever);
			}
			catch(IOException e){
				e.printStackTrace();
			}
		}
		
	}
	


}
